﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;

namespace DbManager.Data
{
    public abstract class DataProvider
    {
        #region Abstract Properties

        public abstract Type ConnectionType { get; }
        public abstract string Name { get; }
        public virtual string ProviderName { get { return ConnectionType.Namespace; } }

        #endregion 

        #region Public Properties

        private string _uniqueName;
        public string UniqueName
        {
            get { return _uniqueName ?? Name; }
            internal set { _uniqueName = value; }
        }


        #endregion 

        #region Abstract Methods

        public abstract IDbConnection CreateConnection();

        #endregion

        #region Factory methods

        public virtual IDbCommand CreateCommand(IDbConnection connection)
        {
            return connection.CreateCommand();
        }

        public virtual IDbDataParameter CreateParameter(IDbCommand command)
        {
            return command.CreateParameter();
        }

        #endregion


    }
}
